import http from "@/http/index";

interface RoleMenuTreeListResponseType {
  roleId:string;
  treeMenuList:Array<UserType.MenuInfo>;
  roleName:string;
  menuList:Array<Omit<UserType.MenuInfo,"children">>
}



export default class RoleApi {
  static getAllRoleList(pageNum:number,pageSize:number):Promise<HttpType.ResponseData<{
    total:number;
    list:Array<UserType.RoleInfo>
  }>>  {
    return http.get("/Role/findAllRoleList",{
      params:{
        pageNum,
        pageSize
      }
    });
  }

  static getRoleMenuTreeList(roleId:string):Promise<HttpType.ResponseData<RoleMenuTreeListResponseType>>  {
    return http.get("/Role/findRoleMenuList",{
      params:{
        roleId
      }
    });
  }
  
  static insertRoleMenuList(roleId:string,menuIdList:Array<string>):Promise<HttpType.ResponseData<number>>  {

    return http({
      method:'post',
      url:'/Role/resetRoleMenuList', 
      data:{
        roleId,
        menuIds: menuIdList
      }
    })
  }

}